package cn.net.shuxing.yifu.common.service;

import cn.net.shuxing.yifu.common.bean.MemberWallet;
import cn.net.shuxing.yifu.common.bean.ShareholderWallet;
import cn.net.shuxing.yifu.common.constant.UserType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

@Service
public class MemberWalletService {

    @Autowired
    private UserInfoService userInfoService;

    @Autowired
    private UserCapitalService userCapitalService;

    @Autowired
    private CashWalletService cashWalletService;

    public MemberWallet getByMemberId(Integer memberId) {
        MemberWallet memberWallet = new MemberWallet();
        memberWallet.setUserInfo(userInfoService.getByPrimaryKey(memberId));
        memberWallet.setUserCashWallet(cashWalletService.getByPrimaryKey(memberId));
        memberWallet.setUserCapitalList(userCapitalService.getsByUserIdAndUserType(memberId, UserType.MEMBER));
        return memberWallet;
    }

    public void addCash(Integer memberId, BigDecimal cashCount,Integer cashChangeType,String orderKey) {
        cashWalletService.addCash(memberId, cashCount,cashChangeType,orderKey);
    }

    public void addAliveCoin(Integer memberId, Integer coinTypeId, BigDecimal aliveCoinCount) {
        userCapitalService.addAliveCoin(memberId, coinTypeId, aliveCoinCount, UserType.MEMBER);
    }

    public void reduceCash(Integer memberId, BigDecimal cashCount,Integer cashChangeType,String orderKey) {
        cashWalletService.reduceCash(memberId, cashCount,cashChangeType,orderKey);
    }

    public void reduceAliveCoin(Integer memberId, Integer coinTypeId, BigDecimal aliveCoinCount) {
        userCapitalService.reduceAliveCoin(memberId, coinTypeId, aliveCoinCount, UserType.MEMBER);
    }
}
